package com.talent.service.impl;

import com.talent.mapper.CategoryMapper;
import com.talent.mapper.SpotMapper;
import com.talent.pojo.entity.Category;
import com.talent.pojo.vo.DashboardOverviewVO;
import com.talent.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 数据看板服务实现类
 */
@Service
public class DashboardServiceImpl implements DashboardService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Autowired
    private SpotMapper spotMapper;

    /**
     * 获取概览数据
     */
    @Override
    public DashboardOverviewVO getOverview() {
        DashboardOverviewVO overview = new DashboardOverviewVO();
        // 点位总数量
        overview.setTotalSpotCount(spotMapper.countAll());
        // 服务站点数量
        Integer serviceCount = categoryMapper.countByType("service");
        overview.setServiceCount(serviceCount);
        // 共享空间数量
        Integer sharedSpaceCount = categoryMapper.countByType("share");
        overview.setShareCount(sharedSpaceCount);
        
        return overview;
    }

    /**
     * 获取公共资源数据
     */
    @Override
    public List<Category> getPublicResourcesData() {
        return categoryMapper.getWithSpotCount("public");
    }

    /**
     * 获取服务站点统计数据
     */
    @Override
    public List<Category> getTalentStations() {
        return categoryMapper.getWithSpotCount("service");
    }
}
